﻿using System;
using System.Collections.Generic;
using System.Data;

namespace BLL.Room
{
  /// <summary>
	/// 业务逻辑类ROOM_EQUIPMENTLAYOUT 的摘要说明。
	/// </summary>
	public class ROOM_EQUIPMENTLAYOUT
	{
		private readonly OracleDAL.Room.ROOM_EQUIPMENTLAYOUT dal=new OracleDAL.Room.ROOM_EQUIPMENTLAYOUT();
		public ROOM_EQUIPMENTLAYOUT()
		{}
		#region  成员方法
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string LOGICEQUIPMENTID)
		{
			return dal.Exists(LOGICEQUIPMENTID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Model.Room.ROOM_EQUIPMENTLAYOUT model)
		{
			dal.Add(model);
		}
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="ID">ID(根据类型有不同的含义，)</param>
        /// <param name="EQUIPMENTTYPE">设备类型</param>
        /// <param name="PCLASS">分类(ROOM 机房，SERVICECONNECTION 服务连接图)</param>
        /// <param name="model">设备布局Model</param>
        public void Add(string ID, string EQUIPMENTTYPE, string PCLASS, Model.Room.ROOM_EQUIPMENT model)
        {
            dal.Add(ID, EQUIPMENTTYPE, PCLASS, model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Model.Room.ROOM_EQUIPMENTLAYOUT model)
        {
            dal.Update(model);
        }
		/// <summary>
		/// 更新一条数据
		/// </summary>
        public void Update(Model.Room.ROOM_EQUIPMENT model)
		{
            Model.Room.ROOM_EQUIPMENTLAYOUT rem = new Model.Room.ROOM_EQUIPMENTLAYOUT();
            rem.LOGICEQUIPMENTID = model.LOGICEQUIPMENTID;
            rem.LOGICEQUIPMENTNAME = model.LOGICEQUIPMENTNAME;
            rem.REMARK = model.REMARK;
            rem.TOP = model.TOP;
            rem.TXTCONTENT = model.TXTCONTENT;
            rem.TXTPROPERTY = model.TXTPROPERTY;
            rem.TYPE = model.TYPE;
            rem.EQUIPMENTPROPERTY = model.EQUIPMENTPROPERTY;
            rem.LEFT = model.LEFT;
            dal.Update(rem);
            Model.Room.ROOM_EQUIPMENTSUPSUB res = new Model.Room.ROOM_EQUIPMENTSUPSUB();
            res.CREATETIME = DateTime.Now;
            res.CREATEUSERISN = "";
            res.EQUIPMENT_PERF = model.EQUIPMENT_PERF;
            res.EQUIPMENTID = model.EQUIPMENTID;
            res.EQUIPTYPE = model.EQUIPTYPE;
            res.ISMONITORALARM = model.ISMONITORALARM;
            res.ISMONITORPERF = model.ISMONITORPERF;
            res.LOGICEQUIPMENTID = model.LOGICEQUIPMENTID;
            res.MODIFYTIME = DateTime.Now;
            res.MODIFYUSERISN = "";
            res.ORDERINDEX = model.ORDERINDEX;
            res.UPLOGICEQUMENTID = model.UPLOGICEQUMENTID;
            new BLL.Room.ROOM_EQUIPMENTSUPSUB().Update(res);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public void Delete(string LOGICEQUIPMENTID)
		{
			
			dal.Delete(LOGICEQUIPMENTID);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.Room.ROOM_EQUIPMENTLAYOUT GetModel(string LOGICEQUIPMENTID)
		{
			
			return dal.GetModel(LOGICEQUIPMENTID);
		}

        ///// <summary>
        ///// 得到一个对象实体，从缓存中。
        ///// </summary>
        //public Model.Room.ROOM_EQUIPMENTLAYOUT GetModelByCache(string LOGICEQUIPMENTID)
        //{
			
        //    string CacheKey = "ROOM_EQUIPMENTLAYOUTModel-" + LOGICEQUIPMENTID;
        //    object objModel = LTP.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = dal.GetModel(LOGICEQUIPMENTID);
        //            if (objModel != null)
        //            {
        //                int ModelCache = LTP.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                LTP.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch{}
        //    }
        //    return (Model.Room.ROOM_EQUIPMENTLAYOUT)objModel;
        //}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.Room.ROOM_EQUIPMENTLAYOUT> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.Room.ROOM_EQUIPMENTLAYOUT> DataTableToList(DataTable dt)
		{
			List<Model.Room.ROOM_EQUIPMENTLAYOUT> modelList = new List<Model.Room.ROOM_EQUIPMENTLAYOUT>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.Room.ROOM_EQUIPMENTLAYOUT model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.Room.ROOM_EQUIPMENTLAYOUT();
					model.LOGICEQUIPMENTID=dt.Rows[n]["LOGICEQUIPMENTID"].ToString();
					model.LOGICEQUIPMENTNAME=dt.Rows[n]["LOGICEQUIPMENTNAME"].ToString();
					model.EQUIPMENTPROPERTY=dt.Rows[n]["EQUIPMENTPROPERTY"].ToString();
					if(dt.Rows[n]["TOP"].ToString()!="")
					{
						model.TOP=int.Parse(dt.Rows[n]["TOP"].ToString());
					}
					if(dt.Rows[n]["LEFT"].ToString()!="")
					{
						model.LEFT=int.Parse(dt.Rows[n]["LEFT"].ToString());
					}
					model.REMARK=dt.Rows[n]["REMARK"].ToString();
					model.TXTCONTENT=dt.Rows[n]["TXTCONTENT"].ToString();
					model.TXTPROPERTY=dt.Rows[n]["TXTPROPERTY"].ToString();
					model.TYPE=dt.Rows[n]["TYPE"].ToString();
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  成员方法
	}
}

